package com.atguigu.chapter04

import scala.util.control.Breaks

object TestWhile {

  def main(args: Array[String]): Unit = {
    var i = 0
    while (i < 10) {
      println("ss" + i)
      i += 1
    }

    try {

      for (elem <- 1 to 10) {
        println(elem)
        if (elem == 5) throw new RuntimeException
      }
    } catch {
      case e =>
    }
    println("循环结束")

    Breaks.breakable(
      for (elem <- 1 to 10) {
        println(elem)
        if (elem==5) Breaks.break()
      }
    )
  }
}
